//package jkgl.ai.service.Impl;
//
//
//import com.alibaba.cloud.ai.tongyi.chat.TongYiChatModel;
//import com.alibaba.dashscope.aigc.generation.GenerationParam;
//import com.alibaba.dashscope.common.Message;
//import com.alibaba.dashscope.common.Role;
//import com.alibaba.dashscope.exception.InputRequiredException;
//import com.alibaba.dashscope.exception.NoApiKeyException;
//import jkgl.ai.service.ChatService;
//import lombok.RequiredArgsConstructor;
//import org.springframework.ai.chat.model.ChatResponse;
//import com.alibaba.dashscope.aigc.generation.Generation;
//import org.springframework.ai.chat.prompt.Prompt;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//@Service
//public class ChatServiceImpl implements ChatService {
//
//    @Resource
//    private TongYiChatModel tongYiChatModel;
//
//    @Override
//    public void chatWithTest(String message) throws NoApiKeyException, InputRequiredException {
//        List<Message> messages = new ArrayList<>();
//        messages.add(createMessage(Role.SYSTEM,"====="));
//        messages.add(createMessage(Role.USER,message));
////        Prompt prompt = new Prompt(messages);
////        ChatResponse call = tongYiChatModel.call(new Prompt(messages));
//        Generation gen = new Generation();
//        Message systemMsg = Message.builder()
//                .role(Role.SYSTEM.getValue())
//                .content("Now, as a health expert, please evaluate the following personal health information and give me some suggestions to ensure good health..")
//                .build();
//        Message userMsg = Message.builder()
//                .role(Role.USER.getValue())
//                .content("你是谁？")
//                .build();
//        GenerationParam param = GenerationParam.builder()
//                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
//                // 模型列表：https://help.aliyun.com/zh/model-studio/getting-started/models
//                .model("qwen-plus")
//                .messages(Arrays.asList(systemMsg, userMsg))
//                .resultFormat(GenerationParam.ResultFormat.MESSAGE)
//                .build();
////        return gen.call(param);
//    }
//
//    public Message createMessage(Role role, String content) {
//        return Message.builder().role(role.getValue()).content(content).build();
//    }
//}
